package com.jy.adscm.operation.lxcg.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.operation.lxcg.bean.LxcgBomSupplier;
import com.jy.adscm.operation.lxcg.bean.LxcgMaterial;
import com.jy.adscm.operation.lxcg.bean.LxcgSupplier;
import com.jy.adscm.operation.lxcg.mapper.mysql.LxcgBomSupplierMapper;
import com.jy.adscm.operation.lxcg.mapper.mysql.LxcgMaterialMapper;
import com.jy.adscm.operation.lxcg.mapper.mysql.LxcgSupplierMapper;
import com.jy.adscm.operation.lxcg.service.LxcgBomSupplierService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * bom与供应商 服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-08-15
 */
@Service
public class LxcgBomSupplierServiceImpl extends ServiceImpl<LxcgBomSupplierMapper, LxcgBomSupplier> implements LxcgBomSupplierService {
    @Autowired
    LxcgSupplierMapper lxcgSupplierMapper;
    @Autowired
    LxcgMaterialMapper lxcgMaterialMapper;
    @Override
    public List<LxcgBomSupplier> selectByBid(Long bid) {
        Wrapper<LxcgBomSupplier> wrapper=new EntityWrapper<>();
        wrapper.eq("bid",bid);
        List<LxcgBomSupplier> lxcgBomSuppliers = super.selectList(wrapper);
        for (LxcgBomSupplier lxcgBomSupplier : lxcgBomSuppliers) {
            LxcgMaterial lxcgMaterial = lxcgMaterialMapper.selectById(lxcgBomSupplier.getBid());
            lxcgBomSupplier.setLxcgMaterial(lxcgMaterial);
            LxcgSupplier lxcgSupplier = lxcgSupplierMapper.selectById(lxcgBomSupplier.getSid());
            lxcgBomSupplier.setLxcgSupplier(lxcgSupplier);
        }
        return lxcgBomSuppliers;
    }
}
